var app = getApp(),
  $ = require("../../utils/httpHelper.js")
Page({
  data: {
    name:'',
    phone:'',
    showdialog: false,
    is_vip:false
  },
  onShareAppMessage: function (res) {
    app.shareApp(res)
  },
  onLoad: function (e) {
    var that = this;
    app.checkVip((data) => {
      if(data){
        this.setData({
          is_vip:true
        })
      }else{
        this.setData({
          is_vip: false
        })
      }
    })
  },
onShow:function(){
  app.checkVip((data) => {
    if (data) {
      this.setData({
        is_vip: true
      })
    } else {
      this.setData({
        is_vip: false
      })
    }
  })
},

  togz() {
    wx.navigateTo({
      url: '/pages/jifen/gz?info=' + 'member'
    })
  },
  showmemberinfo() {
    this.setData({
      showdialog: true
    })
    var rd_session = wx.getStorageSync('rd_session');
    $.httpPost("get_member_infoa", { rd_session: rd_session }, (data, err) => {
      this.setData({
        name:data.data.name,
        phone:data.data.phone
      })
    })
  },
  formSubmit: function (e) {
    var rd_session = wx.getStorageSync('rd_session');
    var param = { rd_session: rd_session, name: e.detail.value.username, phone: e.detail.value.userphone }
    if (app.checkPhone(e.detail.value.userphone)) {
      $.httpPost("edit_member_info", param, (data, err) => {
        wx.showToast({
          title: data.message,
          duration: 2000
        })
        this.setData({
          showdialog: false
        })
      })
    }else{
      wx.showToast({
        title: '手机格式不对哦！~',
        duration: 2000
      })
    }
    console.log('form发生了submit事件，携带数据为：', e.detail.value)
  },
  formReset: function () {
    this.setData({
      showdialog: false
    })
    console.log('form发生了reset事件')
  },
  tomember() {
    wx.navigateTo({
      url: '/pages/mine/sqmember'
    })
  }

});